home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / hungerstrike.swf / scripts / __Packages / actionscript / Interface.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  17.8 KB  |  516 lines

  1. class actionscript.Interface extends MovieClip
  2. {
  3.    var game;
  4.    var info_txt;
  5.    var info2_txt;
  6.    var w2;
  7.    var w3;
  8.    var w4;
  9.    var w5;
  10.    var upgrade_btn;
  11.    var sell_btn;
  12.    var life_btn;
  13.    var _w1Desc;
  14.    var _w2Desc;
  15.    var _w3Desc;
  16.    var _w4Desc;
  17.    var _w5Desc;
  18.    var _weaponSelected;
  19.    var _money;
  20.    var _lives;
  21.    var _score;
  22.    var _hours;
  23.    var _minutes;
  24.    var _seconds;
  25.    var w1;
  26.    var money_txt;
  27.    var lives_txt;
  28.    var level_txt;
  29.    var score_txt;
  30.    var minutes_txt;
  31.    var hours_txt;
  32.    var menu_btn;
  33.    var credits_mc;
  34.    var lives_mc;
  35.    var level_mc;
  36.    var time_mc;
  37.    var pause_btn;
  38.    var sfx_btn;
  39.    var music_btn;
  40.    var seconds_txt;
  41.    function Interface()
  42.    {
  43.       super();
  44.       this._x = 460;
  45.       this._y = 0;
  46.       this.game = this._parent;
  47.       this.info_txt.html = this.info2_txt.html = true;
  48.       this.info_txt.wordWrap = this.info2_txt.html = true;
  49.       this.info_txt.multiline = this.info2_txt.html = true;
  50.       this.info2_txt.html = this.info2_txt.html = true;
  51.       this.info2_txt.wordWrap = this.info2_txt.html = true;
  52.       this.info2_txt.multiline = this.info2_txt.html = true;
  53.       this.init();
  54.    }
  55.    function init()
  56.    {
  57.       this.w2.gotoAndStop("locked");
  58.       this.w3.gotoAndStop("locked");
  59.       this.w4.gotoAndStop("locked");
  60.       this.w5.gotoAndStop("locked");
  61.       this.upgrade_btn.gotoAndStop("idle");
  62.       this.sell_btn.gotoAndStop("idle");
  63.       this.life_btn.gotoAndStop("idle");
  64.       var _loc3_ = this.game.textMessages;
  65.       this._w1Desc = _loc3_._beansDesc;
  66.       this._w2Desc = _loc3_._friesDesc;
  67.       this._w3Desc = _loc3_._pepsiDesc;
  68.       this._w4Desc = _loc3_._wingsDesc;
  69.       this._w5Desc = _loc3_._burgerDesc;
  70.       this._weaponSelected = false;
  71.       this._money = this.game._money;
  72.       this._lives = this.game._lives;
  73.       this._score = 0;
  74.       this._hours = 0;
  75.       this._minutes = 0;
  76.       this._seconds = 0;
  77.       var _loc2_ = 1;
  78.       while(_loc2_ <= 5)
  79.       {
  80.          this["w" + _loc2_]._active = false;
  81.          _loc2_ = _loc2_ + 1;
  82.       }
  83.       this.life_btn._active = false;
  84.       _loc2_ = 2;
  85.       while(_loc2_ <= 5)
  86.       {
  87.          this["w" + _loc2_]._available = false;
  88.          _loc2_ = _loc2_ + 1;
  89.       }
  90.       this.w1._available = true;
  91.       this.setText(this.money_txt,this._money);
  92.       this.setText(this.lives_txt,this._lives);
  93.       this.setText(this.level_txt,this.game._lvl);
  94.       this.setText(this.score_txt,this._score);
  95.       this.setText(this.minutes_txt,"00");
  96.       this.setText(this.hours_txt,"00");
  97.       this.initButtonStates();
  98.       this.checkButtons();
  99.    }
  100.    function initButtonStates()
  101.    {
  102.       var _loc2_ = this.game.textMessages;
  103.       this.w1.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w1);
  104.       this.w1.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w1);
  105.       this.w1.useHandCursor = true;
  106.       this.w2.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w2);
  107.       this.w2.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w2);
  108.       this.w2.useHandCursor = true;
  109.       this.w3.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w3);
  110.       this.w3.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w3);
  111.       this.w3.useHandCursor = true;
  112.       this.w4.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w4);
  113.       this.w4.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w4);
  114.       this.w4.useHandCursor = true;
  115.       this.w5.onPress = actionscript.Proxy.create(this,this.createWeapon,this.w5);
  116.       this.w5.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.w5);
  117.       this.w5.useHandCursor = true;
  118.       this.life_btn.onPress = actionscript.Proxy.create(this,this.addLife);
  119.       this.life_btn.onRollOver = actionscript.Proxy.create(this,this.showInfo,this.life_btn);
  120.       this.life_btn.useHandCursor = true;
  121.       this.menu_btn.onPress = actionscript.Proxy.create(this,this.callMenu);
  122.       this.menu_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._menuOver);
  123.       this.menu_btn.useHandCursor = true;
  124.       this.credits_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._creditsOver);
  125.       this.lives_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._livesOver);
  126.       this.level_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._levelOver);
  127.       this.time_mc.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._timeOver);
  128.       this.upgrade_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._upgradeOver);
  129.       this.upgrade_btn.useHandCursor = true;
  130.       this.sell_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._sellOver);
  131.       this.sell_btn.useHandCursor = true;
  132.       this.pause_btn.onPress = actionscript.Proxy.create(this,this.pauseResume);
  133.       this.pause_btn.useHandCursor = true;
  134.       this.sfx_btn.onPress = actionscript.Proxy.create(this,this.toggleSfx);
  135.       this.sfx_btn.useHandCursor = true;
  136.       this.music_btn.onPress = actionscript.Proxy.create(this,this.toggleMusic);
  137.       this.music_btn.useHandCursor = true;
  138.       for(var _loc3_ in this)
  139.       {
  140.          if(this[_loc3_] instanceof MovieClip && this[_loc3_] != this._parent && this[_loc3_].onRollOver != undefined)
  141.          {
  142.             this[_loc3_].onRollOut = actionscript.Proxy.create(this,this.setText,this.info_txt,"");
  143.          }
  144.       }
  145.    }
  146.    function toggleSfx()
  147.    {
  148.       if(this.game._sfxOn)
  149.       {
  150.          this.sfx_btn.gotoAndStop("off");
  151.          this.game._sfxOn = false;
  152.       }
  153.       else
  154.       {
  155.          this.sfx_btn.gotoAndStop("on");
  156.          this.game._sfxOn = true;
  157.       }
  158.    }
  159.    function toggleMusic()
  160.    {
  161.       if(this.game._musicOn)
  162.       {
  163.          stopAllSounds();
  164.          this.music_btn.gotoAndStop("off");
  165.          this.game._musicOn = false;
  166.       }
  167.       else
  168.       {
  169.          this.game.startSound(this.game._loopSoundName,true);
  170.          this.music_btn.gotoAndStop("on");
  171.          this.game._musicOn = true;
  172.       }
  173.    }
  174.    function pauseResume()
  175.    {
  176.       if(this.game._gamePaused)
  177.       {
  178.          this.pause_btn.gotoAndStop("pause");
  179.          this.game.resumeGame();
  180.       }
  181.       else
  182.       {
  183.          this.pause_btn.gotoAndStop("resume");
  184.          this.game.pauseGame();
  185.          var _loc2_ = this.game.textMessages;
  186.          this.menu_btn.onPress = actionscript.Proxy.create(this,this.callMenu);
  187.          this.menu_btn.onRollOver = actionscript.Proxy.create(this,this.setText,this.info_txt,_loc2_._menuOver);
  188.          this.pause_btn.onPress = actionscript.Proxy.create(this,this.pauseResume);
  189.          this.pause_btn.useHandCursor = true;
  190.          this.menu_btn.useHandCursor = true;
  191.       }
  192.    }
  193.    function resumeGame()
  194.    {
  195.    }
  196.    function deleteButtonStates()
  197.    {
  198.       for(var _loc2_ in this)
  199.       {
  200.          if(this[_loc2_] instanceof MovieClip && this[_loc2_] != this._parent)
  201.          {
  202.             this[_loc2_].useHandCursor = false;
  203.             this[_loc2_].onRelease = undefined;
  204.             this[_loc2_].onPress = undefined;
  205.             this[_loc2_].onRollOver = undefined;
  206.             this[_loc2_].onRollOut = undefined;
  207.          }
  208.       }
  209.    }
  210.    function callMenu()
  211.    {
  212.       this.pause_btn.onPress = undefined;
  213.       this.pause_btn.gotoAndStop("pause");
  214.       this.game.callMenu();
  215.    }
  216.    function showInfo(mW)
  217.    {
  218.       var _loc2_ = this.game.wValue;
  219.       var _loc3_ = this.game.unlockLevel;
  220.       if(!mW._available && mW != this.life_btn)
  221.       {
  222.          switch(mW)
  223.          {
  224.             case this.w2:
  225.                this.setText(this.info_txt,"Fries: " + _loc2_.Fries1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Fries + "!");
  226.                break;
  227.             case this.w3:
  228.                this.setText(this.info_txt,"Pepsi: " + _loc2_.Pepsi1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Pepsi + "!");
  229.                break;
  230.             case this.w4:
  231.                this.setText(this.info_txt,"Chicken Wings: " + _loc2_.Wings1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Wings + "!");
  232.                break;
  233.             case this.w5:
  234.                this.setText(this.info_txt,"Big Daddy Burger: " + _loc2_.Burger1 + " CREDITS<br><br>This weapon will be available at Level " + _loc3_.Burger + "!");
  235.          }
  236.          return undefined;
  237.       }
  238.       switch(mW)
  239.       {
  240.          case this.w1:
  241.             this.setText(this.info_txt,"Beans: " + _loc2_.Beans1 + " CREDITS <br>" + this._w1Desc);
  242.             break;
  243.          case this.w2:
  244.             this.setText(this.info_txt,"Fries: " + _loc2_.Fries1 + " CREDITS<br>" + this._w2Desc);
  245.             break;
  246.          case this.w3:
  247.             this.setText(this.info_txt,"Pepsi: " + _loc2_.Pepsi1 + " CREDITS<br>" + this._w3Desc);
  248.             break;
  249.          case this.w4:
  250.             this.setText(this.info_txt,"Chicken Wings: " + _loc2_.Wings1 + " CREDITS<br>" + this._w4Desc);
  251.             break;
  252.          case this.w5:
  253.             this.setText(this.info_txt,"Big Daddy Burger: " + _loc2_.Burger1 + " CREDITS<br>" + this._w5Desc);
  254.             break;
  255.          case this.life_btn:
  256.             if(this._lives < this.game._maxLives)
  257.             {
  258.                this.setText(this.info_txt,"LIFE:<br>Buy 1 life for " + this.game._lifeValue + " CREDITS.");
  259.             }
  260.             else
  261.             {
  262.                this.setText(this.info_txt,"Maximum " + this.game._maxLives + " lives.");
  263.             }
  264.       }
  265.    }
  266.    function addSeconds()
  267.    {
  268.       this._seconds = this._seconds + 1;
  269.       if(this._seconds == 60)
  270.       {
  271.          this._seconds = 0;
  272.          this._minutes = this._minutes + 1;
  273.          if(this._minutes == 60)
  274.          {
  275.             this._minutes = 0;
  276.             this._hours = this._hours + 1;
  277.             if(this._hours < 10)
  278.             {
  279.                this.setText(this.hours_txt,"0" + this._hours);
  280.             }
  281.             else
  282.             {
  283.                this.setText(this.hours_txt,this._hours);
  284.             }
  285.          }
  286.       }
  287.       if(this._minutes < 10)
  288.       {
  289.          this.setText(this.minutes_txt,"0" + this._minutes);
  290.       }
  291.       else
  292.       {
  293.          this.setText(this.minutes_txt,this._minutes);
  294.       }
  295.       if(this._seconds < 10)
  296.       {
  297.          this.setText(this.seconds_txt,"0" + this._seconds);
  298.       }
  299.       else
  300.       {
  301.          this.setText(this.seconds_txt,this._seconds);
  302.       }
  303.    }
  304.    function createWeapon(mW)
  305.    {
  306.       if(this.game.currentWeapon != undefined)
  307.       {
  308.          this.closeWeaponOptions(this.game.currentWeapon);
  309.       }
  310.       if(this.game._draggingWeapon || this.game._stopped || !mW._active || !mW._available)
  311.       {
  312.          return undefined;
  313.       }
  314.       switch(mW)
  315.       {
  316.          case this.w1:
  317.             this.game.attachMovie("Weapon","Beans" + this.game.w1_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Beans"});
  318.             this.game.w1_counter = this.game.w1_counter + 1;
  319.             this.game._draggingWeapon = true;
  320.             break;
  321.          case this.w2:
  322.             this.game.attachMovie("Weapon","Fries" + this.game.w2_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Fries"});
  323.             this.game.w2_counter = this.game.w2_counter + 1;
  324.             this.game._draggingWeapon = true;
  325.             break;
  326.          case this.w3:
  327.             this.game.attachMovie("Weapon","Pepsi" + this.game.w3_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Pepsi"});
  328.             this.game.w3_counter = this.game.w3_counter + 1;
  329.             this.game._draggingWeapon = true;
  330.             break;
  331.          case this.w4:
  332.             this.game.attachMovie("Weapon","Wings" + this.game.w4_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Wings"});
  333.             this.game.w4_counter = this.game.w4_counter + 1;
  334.             this.game._draggingWeapon = true;
  335.             break;
  336.          case this.w5:
  337.             this.game.attachMovie("Weapon","Burger" + this.game.w5_counter,this.game.getNextHighestDepth(),{_x:-100,_y:-100,_drag:true,_type:"Burger"});
  338.             this.game.w5_counter = this.game.w5_counter + 1;
  339.             this.game._draggingWeapon = true;
  340.       }
  341.    }
  342.    function attachWeaponOptions(mWeapon)
  343.    {
  344.       this.sell_btn.gotoAndStop("normal");
  345.       this.sell_btn.onPress = actionscript.Proxy.create(this,this.sell,mWeapon);
  346.       this.checkButtons();
  347.    }
  348.    function upgrade(mW)
  349.    {
  350.       if(mW._upgradeCost <= this._money && mW._wLevel < 3)
  351.       {
  352.          this.addSubtractMoney(- mW._upgradeCost);
  353.          mW.upgradeWeapon();
  354.       }
  355.       else if(mW._upgradeCost > this._money)
  356.       {
  357.          this.setText(this.info_txt,"You don\'t have enough money to upgrade. You need " + mW._upgradeCost + " CREDITS");
  358.       }
  359.       else if(mW._wLevel >= 3)
  360.       {
  361.          this.setText(this.info_txt,"You reached the max level for this weapon");
  362.       }
  363.    }
  364.    function sell(mW)
  365.    {
  366.       mW.sellWeapon();
  367.    }
  368.    function closeWeaponOptions(mW)
  369.    {
  370.       this.initButtonStates();
  371.       this.sell_btn.gotoAndStop("idle");
  372.       this.sell_btn.onPress = undefined;
  373.       this.upgrade_btn.gotoAndStop("idle");
  374.       this.upgrade_btn.onPress = undefined;
  375.       this.game.currentWeapon = undefined;
  376.       this.game._SellUpgrade = false;
  377.       mW.radius._visible = false;
  378.       this.checkButtons();
  379.    }
  380.    function setText(tTextField, nText)
  381.    {
  382.       tTextField.htmlText = nText.toString();
  383.    }
  384.    function addSubtractMoney(nAmount)
  385.    {
  386.       this._money += nAmount;
  387.       this.setText(this.money_txt,this._money);
  388.       this.checkButtons();
  389.    }
  390.    function addScore(nAmount)
  391.    {
  392.       this._score = Math.round(this._score + nAmount);
  393.       this.setText(this.score_txt,this._score);
  394.    }
  395.    function loseLife()
  396.    {
  397.       this._lives = this._lives - 1;
  398.       if(this._lives <= 0)
  399.       {
  400.          this.game.gameOver();
  401.       }
  402.       this.setText(this.lives_txt,this._lives);
  403.    }
  404.    function addLife()
  405.    {
  406.       if(!this.life_btn._active)
  407.       {
  408.          return undefined;
  409.       }
  410.       if(this._lives < this.game._maxLives)
  411.       {
  412.          this._lives = this._lives + 1;
  413.          this.setText(this.lives_txt,this._lives);
  414.          this.addSubtractMoney(- this.game._lifeValue);
  415.       }
  416.       return undefined;
  417.    }
  418.    function checkButtons()
  419.    {
  420.       if(this.w1._active && this._money < this.game.wValue.Beans1)
  421.       {
  422.          this.w1.gotoAndStop("idle");
  423.          this.w1._active = false;
  424.       }
  425.       else if(!this.w1._active && this._money >= this.game.wValue.Beans1)
  426.       {
  427.          this.w1.gotoAndStop("normal");
  428.          this.w1._active = true;
  429.       }
  430.       if(this.w2._active && this._money < this.game.wValue.Fries1)
  431.       {
  432.          this.w2.gotoAndStop("idle");
  433.          this.w2._active = false;
  434.       }
  435.       else if(!this.w2._active && this._money >= this.game.wValue.Fries1 && this.w2._available)
  436.       {
  437.          this.w2.gotoAndStop("normal");
  438.          this.w2._active = true;
  439.       }
  440.       else if(!this.w2._active && this._money < this.game.wValue.Fries1 && this.w2._available)
  441.       {
  442.          this.w2.gotoAndStop("idle");
  443.       }
  444.       if(this.w3._active && this._money < this.game.wValue.Pepsi1)
  445.       {
  446.          this.w3.gotoAndStop("idle");
  447.          this.w3._active = false;
  448.       }
  449.       else if(!this.w3._active && this._money >= this.game.wValue.Pepsi1 && this.w3._available)
  450.       {
  451.          this.w3.gotoAndStop("normal");
  452.          this.w3._active = true;
  453.       }
  454.       else if(!this.w3._active && this._money < this.game.wValue.Pepsi1 && this.w3._available)
  455.       {
  456.          this.w3.gotoAndStop("idle");
  457.       }
  458.       if(this.w4._active && this._money < this.game.wValue.Wings1)
  459.       {
  460.          this.w4.gotoAndStop("idle");
  461.          this.w4._active = false;
  462.       }
  463.       else if(!this.w4._active && this._money >= this.game.wValue.Wings1 && this.w4._available)
  464.       {
  465.          this.w4.gotoAndStop("normal");
  466.          this.w4._active = true;
  467.       }
  468.       else if(!this.w4._active && this._money < this.game.wValue.Wings1 && this.w4._available)
  469.       {
  470.          this.w4.gotoAndStop("idle");
  471.       }
  472.       if(this.w5._active && this._money < this.game.wValue.Burger1)
  473.       {
  474.          this.w5.gotoAndStop("idle");
  475.          this.w5._active = false;
  476.       }
  477.       else if(!this.w5._active && this._money >= this.game.wValue.Burger1 && this.w5._available)
  478.       {
  479.          this.w5.gotoAndStop("normal");
  480.          this.w5._active = true;
  481.       }
  482.       else if(!this.w5._active && this._money < this.game.wValue.Burger1 && this.w5._available)
  483.       {
  484.          this.w5.gotoAndStop("idle");
  485.       }
  486.       if(this.life_btn._active && this._money < this.game._lifeValue)
  487.       {
  488.          this.life_btn.gotoAndStop("idle");
  489.          this.life_btn._active = false;
  490.       }
  491.       else if(!this.life_btn._active && this._money >= this.game._lifeValue)
  492.       {
  493.          this.life_btn.gotoAndStop("normal");
  494.          this.life_btn._active = true;
  495.       }
  496.       if(this.game._SellUpgrade)
  497.       {
  498.          if(this.game.currentWeapon._upgradeCost <= this._money && this.game.currentWeapon._wLevel < 3)
  499.          {
  500.             this.upgrade_btn.gotoAndStop("normal");
  501.             this.upgrade_btn.onPress = actionscript.Proxy.create(this,this.upgrade,this.game.currentWeapon);
  502.          }
  503.          else if(this.game.currentWeapon._upgradeCost > this._money)
  504.          {
  505.             this.upgrade_btn.gotoAndStop("idle");
  506.             this.upgrade_btn.onPress = undefined;
  507.          }
  508.          if(this.game.currentWeapon._wLevel == 3)
  509.          {
  510.             this.upgrade_btn.gotoAndStop("idle");
  511.             this.upgrade_btn.onPress = undefined;
  512.          }
  513.       }
  514.    }
  515. }
  516.